package com.kfm.shop.controller;

import com.kfm.shop.domain.Product;
import com.kfm.shop.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.util.Date;

@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {

    @Resource
    private ProductService productService;

    @GetMapping("/find/{id}")
    public Product findByPid(@PathVariable("id") Integer pid) {
        log.info("接下来要进行{}号商品信息的查询", pid);
        Product pro = productService.findByPid(pid);
        log.info("商品信息查询成功,内容为{}", pro);
        return pro;
    }

    @RequestMapping("/test")
    public String test() {
        return "product";
    }

    @GetMapping("/getTime")
    public String getTime(@RequestParam Date time) {
        System.out.println(time);
        return "time";
    }

    @PostMapping("/sendTime")
    public String sendTime(@RequestBody Date date) {
        System.out.println(date);
        return "sendTime";
    }
}
